import { IPublicTypeComponentMetadata, IPublicTypeSnippet } from '@alilc/lowcode-types';

const WeatherForecastMeta: IPublicTypeComponentMetadata = {
  componentName: 'WeatherForecast',
  title: '天气预报',
  category: '信息展示',
  group: '气象防灾',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: 'hzdz-charts',
    version: '0.1.0',
    exportName: 'WeatherForecast',
    main: 'src/index.tsx',
    destructuring: true,
    subName: ''
  },
  props: [
    {
      name: 'ref',
      propType: 'object',
    },
    {
      name: 'key',
      propType: 'string',
    },
    {
      name: 'style',
      propType: 'object',
    },
    {
      name: 'className',
      propType: 'string',
    },
    {
      name: 'width',
      propType: 'number',
      description: '组件宽度'
    },
    {
      name: 'height',
      propType: 'number',
      description: '组件高度'
    },
    {
      name: 'weatherData',
      propType: 'object',
      description: '天气数据'
    },
    {
      name: 'showGradientText',
      propType: 'bool',
      description: '显示渐变文字'
    },
    {
      name: 'iconSize',
      propType: 'object',
      description: '图标尺寸'
    },
    {
      name: 'textColors',
      propType: 'object',
      description: '文字颜色配置'
    },
    {
      name: 'theme',
      propType: 'string',
      description: '主题'
    },
    {
      name: 'onClick',
      propType: 'func',
      description: '点击事件'
    },
    {
      name: 'onWeatherIconClick',
      propType: 'func',
      description: '天气图标点击事件'
    }
  ],
  configure: {
    props: [
      {
        name: 'weatherData.forecastTime',
        title: { label: { type: 'i18n', 'en-US': 'weatherData.forecastTime', 'zh-CN': '预报时间' } },
        setter: { componentName: 'StringSetter', isRequired: false, initialValue: '11日13时预报:' }
      },
      {
        name: 'weatherData.currentTime',
        title: { label: { type: 'i18n', 'en-US': 'weatherData.currentTime', 'zh-CN': '当前时间' } },
        setter: { componentName: 'StringSetter', isRequired: false, initialValue: '当时实况(13:45):' }
      },
      {
        name: 'weatherData.weatherType',
        title: { label: { type: 'i18n', 'en-US': 'weatherData.weatherType', 'zh-CN': '天气类型' } },
        setter: { componentName: 'StringSetter', isRequired: false, initialValue: '大雨' }
      },
      {
        name: 'weatherData.weatherIcon',
        title: { label: { type: 'i18n', 'en-US': 'weatherData.weatherIcon', 'zh-CN': '天气图标' } },
        setter: { componentName: 'StringSetter', isRequired: false, initialValue: 'http://localhost:8085/static/images/qixiangfangzhai/yu.png' }
      },
      {
        name: 'weatherData.temperature',
        title: { label: { type: 'i18n', 'en-US': 'weatherData.temperature', 'zh-CN': '温度' } },
        setter: { componentName: 'StringSetter', isRequired: false, initialValue: '20.8℃' }
      },
      {
        name: 'weatherData.feelsLike',
        title: { label: { type: 'i18n', 'en-US': 'weatherData.feelsLike', 'zh-CN': '体感温度' } },
        setter: { componentName: 'StringSetter', isRequired: false, initialValue: '20.7℃' }
      },
      {
        name: 'weatherData.humidity',
        title: { label: { type: 'i18n', 'en-US': 'weatherData.humidity', 'zh-CN': '湿度' } },
        setter: { componentName: 'StringSetter', isRequired: false, initialValue: '98%' }
      },
      {
        name: 'weatherData.pressure',
        title: { label: { type: 'i18n', 'en-US': 'weatherData.pressure', 'zh-CN': '气压' } },
        setter: { componentName: 'StringSetter', isRequired: false, initialValue: '1012hpa' }
      },
      {
        name: 'weatherData.windDirection',
        title: { label: { type: 'i18n', 'en-US': 'weatherData.windDirection', 'zh-CN': '风向' } },
        setter: { componentName: 'StringSetter', isRequired: false, initialValue: '东北偏东风' }
      },
      {
        name: 'weatherData.windLevel',
        title: { label: { type: 'i18n', 'en-US': 'weatherData.windLevel', 'zh-CN': '风力' } },
        setter: { componentName: 'StringSetter', isRequired: false, initialValue: '1级' }
      },
      {
        name: 'showGradientText',
        title: { label: { type: 'i18n', 'en-US': 'showGradientText', 'zh-CN': '显示渐变文字' } },
        setter: { componentName: 'BoolSetter', isRequired: false, initialValue: true }
      }
    ],
    supports: {
      style: true
    }
  }
};

const snippets: IPublicTypeSnippet[] = [
  {
    title: '天气预报',
    screenshot: '',
    schema: {
      componentName: 'WeatherForecast',
      props: {
        width: 500,
        height: 120,
        weatherData: {
          forecastTime: '11日13时预报:',
          currentTime: '当时实况(13:45):',
          weatherType: '大雨',
          weatherIcon: 'http://localhost:8085/static/images/qixiangfangzhai/yu.png',
          temperature: '20.8℃',
          feelsLike: '20.7℃',
          humidity: '98%',
          pressure: '1012hpa',
          windDirection: '东北偏东风',
          windLevel: '1级'
        },
        showGradientText: true,
        iconSize: {
          width: 46,
          height: 46
        },
        textColors: {
          time: 'rgba(255,255,255,0.6)',
          label: 'rgba(255,255,255,0.8)',
          value: '#1AD7FF',
          weather: '#FFFFFF'
        },
        theme: 'dark'
      }
    }
  }
];

export default {
  ...WeatherForecastMeta,
  snippets
};
